<?php
// 动态获取当前选中的select宠物的基本信息
// header("content-type:text/html;charset=UTF-8");
include_once("conn.php");
include_once("u_getLoginInfo.php");
if ($_GET['petlist'] != "none") {
    $petID = $_GET['petlist'];
    $sql_pet = "SELECT * FROM pet_infos WHERE pet_ID = '" . $petID . "'";

    $result_pet = mysqli_query($connect_DB, $sql_pet);
    if ($result_pet) {
        $row_pet = mysqli_fetch_object($result_pet);
        echo "
        <div class='col-6'>
            <label for='petID' class='form-label'>宠物ID</label>
            <input type='text' class='form-control' id='petID' name='petID' value='".$petID."' required readonly>
        </div>
        <div class='col-3'>
            <label for='petName' class='form-label'>宠物昵称</label>
            <input type='text' class='form-control' id='petName' name='petName' value='".$row_pet->pet_Name."' required readonly>
        </div>
        <div class='col-3'>
            <label for='petType' class='form-label'>宠物类型</label>
            <input type='text' class='form-control' id='petType' name='petType' value='".$row_pet->pet_Type."' required readonly>
        </div>
        ";
    } else {
        echo "执行查询失败：<br>" . $sql_pet;
    }
}else{
    echo "
    <div class='col-6'>
        <label for='petID' class='form-label'>宠物ID</label>
        <input type='text' class='form-control' id='petID' name='petID' value='待选择' required disabled>
    </div>
    <div class='col-3'>
        <label for='petName' class='form-label'>宠物昵称</label>
        <input type='text' class='form-control' id='petName' name='petName' value='待选择' required disabled>
    </div>
    <div class='col-3'>
        <label for='petType' class='form-label'>宠物类型</label>
        <input type='text' class='form-control' id='petType' name='petType' value='待选择' required disabled>
    </div>
    ";
}

$connect_DB->close();
?>